/**
 * 
 */
package archsw0904.controller.shopping.common;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;

import archsw0904.model.Book;


/**
 * @author ASGroup0904
 *
 */
public class BookListVisualizationInfo{
	
	private BigDecimal totalPrice ;
	private ArrayList<BookInfo> bookList = new ArrayList<BookInfo>();
	private BookInfo arrayBookInfo[] = new BookInfo[0]; 
	
	public BookInfo[] getArrayBookInfo() {
		Arrays.sort(arrayBookInfo);
		return arrayBookInfo;
	}
	
	public void setArrayBookInfo(BookInfo[] arrayBookInfo) {
		this.arrayBookInfo = arrayBookInfo;
	}
	
	public void setTotalPrice(BigDecimal totalPrice) {
		this.totalPrice = totalPrice;
	}
	
	public BigDecimal getTotalPrice() {
		return totalPrice;
	} 
	
	public ArrayList<BookInfo> getBookList () {
		return bookList ;
	}
	
	public Boolean addBook ( Book book , Integer nCopies ) {
		BookInfo item = new BookInfo ( book , nCopies ) ;
		Boolean added;
		if ( bookList.contains(item) )
			return false ;
		added = bookList.add(item);
		setArrayBookInfo( bookList.toArray(arrayBookInfo) );
		return added;
	}



}
